package techLayer;

import java.awt.Color;
import java.awt.GridLayout;
import java.util.Iterator;
import javax.swing.JDialog;
import javax.swing.JTextArea;

public class HighscoreFrame extends JDialog{
    
    public HighscoreFrame(Iterator it){
        setTitle("Highscore");
        setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        setLocationRelativeTo(null);
        setLayout(new GridLayout(25,1));
        setSize(800,600);

        setLocation(140,30);
        setVisible(true);
        
        showInfo(it);
    }
    public void showInfo(Iterator it){
        Boolean green = true;
        JTextArea top = new JTextArea("NAME\t\tWINS\t\tLOSSES");
        add(top);
        while(it.hasNext()){
            ScoreRow row = (ScoreRow) it.next();
            JTextArea text = new JTextArea(row.getName() + "\t\t" + row.getWins() + "\t\t" + row.getLoss());
            if(green){
                text.setBackground(Color.GREEN);
                green = false;
            }else{
                text.setBackground(Color.CYAN);
                green = true;
            }
            add(text);
        }
    }
}
